/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef GEN_PCIe_DEVICE_INTERFACE_H
#define GEN_PCIe_DEVICE_INTERFACE_H

#include <device_tree/base.h>

namespace dev::gen {

class MC_API PCIeDevice : public mc::engine::interface<PCIeDevice> {
public:
    MC_INTERFACE("bmc.dev.PCIeDevice")

    property<std::string> DeviceName;         ///< 设备资源名称
    property<uint8_t>     FunctionClass;      ///< 功能分类
    property<std::string> VendorId;           ///< 制造商ID
    property<std::string> DeviceId;           ///< 设备ID
    property<std::string> SubSystemVendorId;  ///< 子厂商ID
    property<std::string> SubSystemDeviceId;  ///< 子设备ID
    property<std::string> Location;           ///< 当前PCIe的物理位置
    property<uint8_t>     Slot;               ///< PCIe设备的物理槽位号
    property<uint8_t>     Segment;            ///< 用于多PCI Bridge场景的编号
    property<uint8_t>     SocketId;           ///< PCIe设备所属CPU ID
    property<uint8_t>     Bus;                ///< PCIe Root Port的总线号
    property<uint8_t>     Device;             ///< PCIe Root Port的设备号
    property<uint8_t>     Function;           ///< PCIe Root Port的功能号
    property<uint8_t>     DevBus;             ///< 设备的总线号
    property<uint8_t>     DevDevice;          ///< 设备的设备号
    property<uint8_t>     DevFunction;        ///< 设备的功能号
    property<uint8_t>     DiagnosticFault;    ///< 诊断故障标志
    property<uint8_t>     PredictiveFault;    ///< 预故障标志
    property<uint8_t>     UCEByBIOS;          ///< BIOS上报不可纠正错误标识
    property<uint8_t>     BandwidthReduction; ///< PCIE降带宽检测失败上报事件属性
    property<uint8_t>     LinkSpeedReduced;   ///< PCIE设备降速率检测告警上报事件属性
    property<std::string> SlotType;           ///< PCIe设备所在槽位的类型
    property<std::string> FunctionProtocol;   ///< PCIe功能协议
    property<std::string> FunctionType;       ///< PCIe功能类型
    property<uint8_t>     ComponentType;      ///< PCIe设备部件类型
    property<std::string> Container;          ///< 容纳PCIe设备的部件名称
    property<std::string> DeviceType;         ///< PCIe设备类型
    property<std::string> GroupPosition;      ///< PCIe设备唯一标识

    virtual bool SetRootBDF(uint8_t bus, uint8_t device, uint8_t function)   = 0;
    virtual bool SetDeviceBDF(uint8_t bus, uint8_t device, uint8_t function) = 0;
};
} // namespace dev::gen

#endif // GEN_PCIe_DEVICE_INTERFACE_H